/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iteracon.tuple.iterator;

import java.util.Iterator;
import iteracon.IteraconBase;
import iteracon.tuple.Tpl;

/**
 * simple fast iterator for tuple
 * @author martin
 */
public class TupleIterator<T> implements Iterator<T>{
  private final Tpl<T> _t;
  private int _index;
  /**
   * constructor
   * @param t as Tuple
   */
  public TupleIterator(Tpl<T> t){
    _t = t;
    _index=0;
  }
  
  @Override
  public boolean hasNext() {
    return _index < _t.size()-1;
  }

  @Override
  public T next() {
    return _t.get(++_index);
  }

  @Override
  public void remove() {
    throw new UnsupportedOperationException("tuple is immutable");
  }

}
